import axios from "axios";
export default {
  // 根据url下载文件
  downLoad(url, name = Date.now()) {
    if (!url) return;
    axios({
      method: "get",
      url,
      responseType: "blob"
    }).then(res => {
      let elink = document.createElement("a");
      const fileType = res.headers["content-type"].split("/")[1];
      elink.download = name + "." + fileType;
      elink.href = URL.createObjectURL(res.data);
      elink.click();
    });
  }
};
